package com.pmpd.activity.service.api.impl;

import com.pmpd.activity.dao.ActivityTaskMapper;
import com.pmpd.activity.po.ActivityTask;
import com.pmpd.activity.po.ActivityTaskExample;
import com.pmpd.activity.service.api.ApiActivityTaskService;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

/**
 * @Author liuying
 * @Description 活动任务服务层实现
 * @Date 15:06 2018/6/7
 */
@Service
public class ApiActivityTaskServiceImpl implements ApiActivityTaskService{

    @Resource
    private ActivityTaskMapper activityTaskMapper;

    @Override
    public List<ActivityTask> selectByType(long activityId, int type) {
        ActivityTaskExample example = new ActivityTaskExample();
        example.setOrderByClause("task_day asc");
        ActivityTaskExample.Criteria criteria = example.createCriteria();
        criteria.andActivityIdEqualTo(activityId);
        criteria.andTypeEqualTo(type);
        return activityTaskMapper.selectByExample(example);
    }

    @Override
    public ActivityTask selectByTypeAndDay(long activityId, int type, int taskDay) {
        ActivityTaskExample example = new ActivityTaskExample();
        ActivityTaskExample.Criteria criteria = example.createCriteria();
        criteria.andActivityIdEqualTo(activityId);
        criteria.andTypeEqualTo(type);
        criteria.andTaskDayEqualTo(taskDay);
        return activityTaskMapper.selectByExample(example).get(0);
    }
}
